home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c++
- Path: lade.news.pipex.net!pipex!insignia!franc
- From: William.Charnell@isltd.insignia.com (William Charnell)
- Subject: Re: C++ keyword
- Message-ID: <DoBAGv.IAz@isltd.insignia.com>
- Sender: news@isltd.insignia.com
- Nntp-Posting-Host: franc.isltd.insignia.com
- Organization: Insignia Solutions
- X-Newsreader: News Xpress 2.0 Beta #0
- References: <mwoods-1403961501550001@ou048057.otago.ac.nz>
- Date: Fri, 15 Mar 1996 13:58:24 GMT
-
- In article <mwoods-1403961501550001@ou048057.otago.ac.nz>, mwoods@maths.otago.ac.nz (Matt B. Woods) wrote:
- >I am fairly new to C++ and I have just come across the keyword 'throw'.
- >As I cannot find a reference to this keyword I assume I must be reading
- >the wrong books. Can anyone tell me what 'throw' means? Even better
- >could someone recommend a good complete reference to the C++ language?
-
- The standard reference is Bjarne Stroustrup's "C++ reference manual" or
- perhaps the annotated version (authored by Stroustrup and Margaret Ellis).
-
- As regards "throw", it is to do with exception handling and is associated
- with the "try" and "catch" keywords. The idea is that you can avoid having to
- check whether functions return sensible values at various levels in a nested
- sequence of function calls by wrapping the whole complex sequence at the
- highest level in a "try" block with an appropriate "catch" exception handler
- after it. Such as:
-
- try
- {
- <complex seqence>
- }
- catch (<exception params>)
- {
- <handler code>
- }
-
- where any of the functions called in the <compex sequence> can say:
-
- throw <exception params>
-
- to abort the complex sequence and jump to the handler code (in the "catch"
- block).
-
- This is not a complete (or indeed completely accurate) account of exceptions
- in C++. You are better off going to a good C++ text boot. Also excpetions
- (like templates etc.) are not necessarily implemented by all C++ compilers.
-
- Hope this helps
-
- William Charnell
-